use super::singly_linked::ListNode;

fn reverse_list(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> {
  let mut current = &head;
  let mut previous = None;
  while let Some(node) = current {
    previous = Some(Box::new(ListNode { next: previous, val: node.val }));
    current = &node.next;
  }
  previous
}
